﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace PlusMinus_WEB
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        { }
            private void button1_Click(object sender, EventArgs e)
        {


        }

        private void button2_Click(object sender, EventArgs e)
        {}
            


        protected void Button2_Click1(object sender, EventArgs e)
        {
                        Match match1Dod = Regex.Match(textBox1.Text, "^[0-9]+$");
            Match match1Ujemna = Regex.Match(textBox1.Text, "^-[0-9]+$");
            Match match2Dod = Regex.Match(textBox2.Text, "^[0-9]+$");
            Match match2Ujemna = Regex.Match(textBox2.Text, "^-[0-9]+$");
            if (match1Dod.Success || match1Ujemna.Success)
            {
                if( match2Dod.Success || match2Ujemna.Success)
            {
                
                double a = Double.Parse(textBox1.Text);
                double b = Double.Parse(textBox2.Text);
                    double wynik = a - b;
                    label1.Text = wynik.ToString();
            }
            else
            {
ErrorMsg();
            }
            }
            else
            {
ErrorMsg();
            }
        }
        void ErrorMsg()
        {
            label1.Text = "WPROWADŹ 2 LICZBY CAŁKOWITE";
        }

        protected void Button1_Click1(object sender, EventArgs e)
        {
                        Match match1Dod = Regex.Match(textBox1.Text, "^[0-9]+$");
            Match match1Ujemna = Regex.Match(textBox1.Text, "^-[0-9]+$");
            Match match2Dod = Regex.Match(textBox2.Text, "^[0-9]+$");
            Match match2Ujemna = Regex.Match(textBox2.Text, "^-[0-9]+$");
            if (match1Dod.Success || match1Ujemna.Success)
            {
                if( match2Dod.Success || match2Ujemna.Success)
            {
                double a = Double.Parse(textBox1.Text);
                double b = Double.Parse(textBox2.Text);
                    double wynik = a + b;
                    label1.Text = wynik.ToString();
            }
            else
            {
ErrorMsg();
            }
            }
            else
            {
ErrorMsg();
            }
        }
        }
        }
    
